<template>
<div class="recoredcontent">
    <block v-if="list.length">
       <div class="box" v-for="(item,index) in list" :key="index">
           <div class="box_icon">
               <img :src="item.cover" alt="">
           </div>
           <div class="box_banner">
               <div class="box_banner_ins">
                   <div class="box_banner_ins_til">{{item.shop_name}}</div>
                   <span class="box_banner_ins_tag">{{item.recharge_mode}}</span>
               </div>
               <div class="box_banner_pink">
                   <div class="box_banner_pink_lump">{{item.updated_at}}</div>
                   <!-- <div class="box_banner_pink_lump">  12</div> -->
               </div>
               <div class="box_banner_text">
                   ￥{{item.total}}
               </div>
           </div>
       </div>
    </block>
    <ListEmpty v-else />

    </div>
</template>

<script lang="ts">
import store from '@/store';
import { api } from '@/lib/api';
import ListEmpty from '@/components/list/listEmpty.vue';
import { EMPTY_LIST, ROUTE_NAME } from '@/lib/constant';
import { Component, Vue, Watch } from 'vue-property-decorator';

@Component({
    name: 'rechargeRecordList',
    components: {
        ListEmpty
    }
})

export default class rechargeRecordList extends Vue {

    public get getrechargeRecoredListMap(){
        return store.state.shop.rechargeRecoredList;
    }

    public get getrechargeRecoredList(){
        return this.getrechargeRecoredListMap['null'] || EMPTY_LIST;;
    }
    
    public get list(){
        return this.getrechargeRecoredList.list;
    }

    // 上啦加载
    public async onReachBottom() {
        store.commit('utils/startRequest');
        await store.dispatch('shop/getrechargeRecoredList', {
            offset: this.list.length,
            count: 10,
        });
        
        store.commit('utils/endRequest');
    }

    // 下拉刷新
    async onPullDownRefresh() {
        await store.dispatch('shop/getrechargeRecoredList', {
            offset: 0,
            count: 10,
            forceUpdate: true
        });
    }

    public async created() {
        store.commit('utils/startRequest');
        await store.dispatch('shop/getrechargeRecoredList', {
            offset: 0,
            count: 10,
            forceUpdate: true
        });
        store.commit('utils/endRequest');

        window.addEventListener('reachbottom', this.onReachBottom);
        window.addEventListener('pulldownrefresh', this.onPullDownRefresh);
    }
    public beforeDestroy() {
        window.removeEventListener('reachbottom', this.onReachBottom);
        window.removeEventListener('pulldownrefresh', this.onPullDownRefresh);
    }
}
</script>
<style lang="less">

.recoredcontent{
    width: 100%;
    min-height: 100vh;
    // overflow: hidden;
    // overflow-y: scroll;
    background-color: #F8F8F8;
    .box{
        width: 92%;
        display: flex;
        // justify-content: space-around;
        justify-content: space-evenly;
        background-color: #ffffff;
        border-radius: 10rpx;
        padding: 10rpx 0rpx;
        margin: 0rpx auto;
        .box_icon{
            width: 90rpx;
            height: 90rpx;
            margin-top: 20rpx;
            img{
                width: 90rpx;
                height: 90rpx;
                border-radius: 30rpx;
                background-color: #E6E6E6;
            }
        }
        .box_banner{
            width: 82%;
            height: 120rpx;
            // line-height: 120rpx;
            display: flex;
            justify-content: space-around;
            border-bottom: 1rpx solid #cccccc;
            .box_banner_ins{
                width: 38%;
                font-size: 28rpx;
                color: #000;

                .box_banner_ins_til{
                    height: 70rpx;
                    line-height: 90rpx;
                    font-weight: 600;
                    color: #797979;
                    overflow: hidden;
                    text-overflow:ellipsis;
                    white-space: nowrap;
                }
                .box_banner_ins_tag{
                    background-color: #FE939D;
                    border-radius: 100rpx;
                    color: #ffffff;
                    font-size: 20rpx;
                    padding: 4rpx 8rpx;
                }
            }
            .box_banner_pink{
                width: 24%;
                font-size: 22rpx;
                color: silver;
                padding-top: 27rpx;
                // span{
                //     display: inline-block;
                // }
                .box_banner_pink_lump{
                    width: 100%;
                    height: 40rpx;
                    line-height: 40rpx;
                    text-align: center;
                }
            }
            .box_banner_text{
                width: 30%;
                line-height: 120rpx;
                font-size: 30rpx;
                text-align: right;
                font-weight: 600;
                color: crimson;
            }
        }
    }
}
</style>
